(define (domain neuhelium_coffee)

    (:requirements :strips :typing :fluents :durative-actions :negative-preconditions)

    (:types
        delivery_robot robotic_arm location coffee coffee_machine coffee_order
    )

    (:predicates
        (device_available ?dr - delivery_robot ?ra - robotic_arm)
        (order_obtained ?co - coffee_order)

        (coffee_ready ?co - coffee_order ?cm - coffee_machine ?c - coffee)
        (coffee_notready ?co - coffee_order ?c - coffee)
        (at_location ?dr - delivery_robot ?loc - location)

        (arm_empty ?ra - robotic_arm)
        (arm_hold ?ra - robotic_arm ?c - cup)
        ;
        ; (cup_near_coffeemachine ?ra)
        ; (cup_near_coffeemachine ?ra)
        (cabin_unvisited ?dr - delivery_robot ?loc - location)
        (cabin_visited ?dr - delivery_robot ?loc - location)
        (hatch_opened ?dr - delivery_robot)
        (hatch_closed ?dr - delivery_robot)

        (payload_empty ?dr - delivery_robot)
        (payload_carried ?dr - delivery_robot)

        (coffee_obtained ?dr - delivery_robot ?loc - location ?c - coffee)
        (coffee_served ?dr - delivery_robot ?co - coffee_order ?loc - location)

        ; (charging ?r - delivery_robot)
        ; (battery_high ?r - delivery_robot)
        ; (battery_low ?r - delivery_robot)
    )

    (:functions

    )

    (:durative-action get_order
        :parameters (?ra - robotic_arm ?dr - delivery_robot ?co - coffee_order)
        :duration (= ?duration 1)
        :condition (and
            (at start (and (device_available ?dr ?ra)
                ))
        )
        :effect (and
            (at end (and (order_obtained ?co)
                ))
        )
    )

    (:durative-action move_into_cabin
        :parameters (?dr - delivery_robot ?from ?cabin - location ?co - coffee_order)
        :duration (= ?duration 1)
        :condition (and
            (at start (and
                    (cabin_unvisited ?dr ?cabin)
                    (at_location ?dr ?from)
                    (order_obtained ?co)
                ))
        )
        :effect (and
            (at start (and
                    (not (at_location ?dr ?from))
                ))

            (at end (and
                    (cabin_visited ?dr ?cabin)
                    (at_location ?dr ?cabin)
                ))

        )
    )

    (:durative-action get_cup
        :parameters (?ra - robotic_arm ?co - coffee_order ?c - cup)
        :duration (= ?duration 1)
        :condition (and
            (at start (and
                    (arm_empty ?ra)
                    ; (coffee_notready ?co ?c)
                ))
            (over all (and (order_obtained ?co)))
        )
        :effect (and
            (at end (and
                    (arm_hold ?ra ?c)
                    
                ))
        )
    )

    (:durative-action make_coffee
        :parameters (?ra - robotic_arm ?co - coffee_order ?cm - coffee_machine ?c - coffee)
        :duration (= ?duration 1)
        :condition (and
            (at start (and
                    ; (coffee_notready ?co ?cm ?c)
                    (order_obtained ?co)
                ))
            (over all (and (arm_hold ?ra ?c)))
        )
        :effect (and
            (at end (and
                    (coffee_ready ?co ?cm ?c)
                ))
        )
    )

    ; (:durative-action open_hatch
    ;     :parameters (?dr - delivery_robot)
    ;     :duration (= ?duration 5)
    ;     :condition (and 
    ;         (at start (and (hatch_closed ?dr)
    ;         ))
    ;     )
    ;     :effect (and 
    ;         (at end (and (hatch_opened ?dr)
    ;         ))
    ;     )
    ; )

    ; (:durative-action close_hatch
    ;     :parameters (?dr - delivery_robot)
    ;     :duration (= ?duration 5)
    ;     :condition (and 
    ;         (at start (and (hatch_opened ?dr)
    ;         ))
    ;     )
    ;     :effect (and 
    ;         (at end (and (hatch_closed ?dr)
    ;         ))
    ;     )
    ; )

    (:durative-action place_cup_into_delivery_robot
        :parameters (?dr - delivery_robot ?ra - robotic_arm ?cabin - location ?co - coffee_order ?cm - coffee_machine ?c - coffee)
        :duration (= ?duration 1)
        :condition (and
            (at start (and
                    (arm_hold ?ra ?c)
                    (coffee_ready ?co ?cm ?c)
                    (payload_empty ?dr)
                    (cabin_visited ?dr ?cabin)
                ))
        )
        :effect (and
            (at start (not (arm_hold ?ra ?c)))

            (at end (and
                    (arm_empty ?ra)
                    (payload_carried ?dr)
                    (coffee_obtained ?dr ?cabin ?c)
                    ; (coffee_notready ?co ?cm ?c)
                ))
        )
    )

    (:durative-action deliver_coffee
        :parameters (?dr - delivery_robot ?ra - robotic_arm ?cabin ?to - location ?co - coffee_order ?c - coffee)
        :duration (= ?duration 1)
        :condition (and
            (at start (and
                    (arm_empty ?ra)
                    (payload_carried ?dr)
                    (at_location ?dr ?cabin)
                    (coffee_obtained ?dr ?cabin ?c)
                ))
        )
        :effect (and
            (at start (and
                    (not (at_location ?dr ?cabin))
                ))

            (at end (and
                    ; (payload_empty ?dr)
                    (at_location ?dr ?to)
                    (coffee_served ?dr ?co ?to)
                ))
        )
    )

)